<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<script language="JavaScript">

//
//
//
function doQualifiersEdit(form) {
  var selectedIds = "";
  selectedIds += "<c:forEach var="qualifier" items="${qualifiers}"><c:out value="${qualifier.map.id}"/>;</c:forEach>";
  selectedIds += "<c:forEach var="qualifier" items="${jumbos}"><c:out value="${qualifier.map.id}"/>;</c:forEach>";
  doPickerPopupAction('<c:url value="/mt/categorySearchPickerPopupMultiSelect.do"/>', 'setQualifiers', 315, null, selectedIds, null, false, true);
}

//
//
//
function doQualifierValuesEdit(qualifierId, selectedIds) {
  setQualifierId(qualifierId);
  doPickerPopupAction('<c:url value="/mt/pickerPopupSearchMultiSelect.do"/>', 'setQualifierValues', 315, qualifierId, selectedIds, "FRIENDLY_NAME", false, true, false, null, null, null, null, null, null, false);
}

</script>

<%@include file="/mt/common/pickerPopupHelper.jsp" %>

<c:set var="editImg">
<img src="<%= request.getContextPath() %>/ep/images/action/icon_edit.gif" width="15" height="15" class="actionIcon" border="0" alt='<bean-el:message key="image.alt.edit" bundle="ep.messages"/>' title='<bean-el:message key="image.alt.edit" bundle="ep.messages"/>' >
</c:set>
<c:set var="removeImg">
<img src="<%= request.getContextPath() %>/ep/images/action/icon_remove.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.remove" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.remove" bundle="ep.messages"/>">
</c:set>

<input type="hidden" name="qualifierId"/>
<input type="hidden" name="qualifierType"/>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">

      <div class="pageTitle">
        <c:out value="${pageTitle}"/>
      </div> 

      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>
      <!-- for program breadcrumbs -->
      <div class="breadcrumb">
      <c:if test="${not empty epProgramView.map.breadcrumbs}">
        <c:forEach var="channel" items="${epProgramView.map.breadcrumbs}" varStatus="index">
          <c:url var="browseUrl" value="/ep/channelBrowse.do">
            <c:param name="channelId" value="${channel.map.id}"/>
          </c:url>
          <c:if test="${index.count > 1}"><bean-el:message key="ep.breadcrumb.delimiter" bundle="ep.messages"/>&nbsp;</c:if><a href="<c:out value="${browseUrl}"/>"><c:out value="${channel.map.name}"/></a>
        </c:forEach>
      </c:if>
<!-- for channel breadcrumbs -->
      <c:if test="${not empty epChannelView.map.breadcrumbs}">
        <c:forEach var="channel" items="${epChannelView.map.breadcrumbs}" varStatus="index">
          <c:url var="browseUrl" value="/ep/channelBrowse.do">
            <c:param name="channelId" value="${channel.map.id}"/>
          </c:url>
          <c:if test="${index.count > 1}"><bean-el:message key="ep.breadcrumb.delimiter" bundle="ep.messages"/>&nbsp;</c:if><a href="<c:out value="${browseUrl}"/>"><c:out value="${channel.map.name}"/></a>
        </c:forEach>
      </c:if>
      </div>

      <div class="pageSubtitle">
        <span class="left">
          <bean-el:message key="ep.qualifier.value.object.selected.qualifiers" bundle="ep.messages"/>
        </span>

        <span class="right">
<c:if test="${editable}">
          <html-el:button styleClass="inputButton" property="selectBtn" onclick="return doQualifiersEdit(this.form)">
            <bean-el:message key="button.qualifiers.select" bundle="ep.messages"/>
          </html-el:button>
</c:if>
        </span>
      </div>
      
<c:if test="${not empty qualifiers || not empty jumbos}">
      <div class="pageInstructions"><bean-el:message key="ep.qualifier.value.object.specify.no.values" bundle="ep.messages"/></div>
</c:if>
      
<c:if test="${not empty qualifiers}">
      <div class="pageSubsubtitle">
        <span class="left"><bean-el:message key="ep.qualifier.value.object.reqular.subsubtitle" arg0="${jumbo_threshold}" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div> 
  <c:if test="${editable}">
      <div class="globalButtonWrap">
        <input type="button" name="selectAllQualifiers" class="globalButton" value="<bean-el:message key="button.selectAll" bundle="ep.messages"/>"
          onclick="check(this.form.qualifierIds, this);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.edit" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.qualifierIds, '<bean-el:message key="ep.qualifier.atLeastOne" bundle="ep.messages"/>')) doQualifierValuesMultiEdit(0)">
        <input type="button" class="globalButton" value="<bean-el:message key="button.remove" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.qualifierIds, '<bean-el:message key="ep.qualifier.atLeastOne" bundle="ep.messages"/>')) doQualifierRemove(0);">
      </div>
  </c:if>

      <!--start main content area here-->
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Category" width="100%">
        <tr class="listHeader"> 
  <c:if test="${editable}">
          <th id="Checkboxes">&nbsp;</th>
  </c:if>
          <th id="Name" align="left" width="30%">
            <bean-el:message key="ep.qualifier.value.object.qualifier" bundle="ep.messages"/>
          </th>
          <th id="Value" align="left" width="60%">
            <bean-el:message key="ep.qualifier.value.object.specified.values" bundle="ep.messages"/>
          </th>
  <c:if test="${editable}">
          <th id="Actions" align="left" width="10%">
            <bean-el:message key="ep.header.actions" bundle="ep.messages"/>
          </th>
  </c:if>
        </tr>

    <c:forEach var="qualifier" items="${qualifiers}" varStatus="status">

      <c:choose>
        <c:when test="${(status.count + 1) % 2 == 0}">
        <tr class="listEven">
        </c:when> 
        <c:otherwise>
        <tr class="listOdd">
        </c:otherwise>
      </c:choose>

      <c:if test="${editable}">
          <td headers="Checkboxes" align="center"><input type="checkbox" name="qualifierIds"
            onclick="update(this.form.qualifierIds, this.form.selectAllQualifiers);"
            value="<c:out value="${qualifier.map.id}"/>"></td>
      </c:if>
          <td headers="Name">
            <c:out value="${qualifier.map.name}" />
          </td>
          <td headers="Value">
            <c:forEach var="value" items="${qualifier.map.selectedValues}" varStatus="valueStatus"><c:if test="${valueStatus.count != 1}">, </c:if><c:out value="${value.map.name}"/></c:forEach>
          </td>
      <c:if test="${editable}">
          <td headers="Actions">
            <a href="#" onclick="doQualifierValuesMultiEdit(<c:out value="${qualifier.map.id}"/>);"><c:out
            value='${editImg}' escapeXml="false"/></a>
            <a href="#" onclick="doQualifierRemove(<c:out value="${qualifier.map.id}"/>);"><c:out
            value='${removeImg}' escapeXml="false"/></a>
          </td>
      </c:if>
        </tr>      
        
    </c:forEach>
      </table>
</c:if>

<c:if test="${not empty jumbos}">
      <div class="pageSubsubtitle">
        <span class="left"><bean-el:message key="ep.qualifier.value.object.jumbo.subsubtitle" arg0="${jumbo_threshold}" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div> 
  <c:if test="${editable}">
      <div class="globalButtonWrap">
        <input type="button" name="selectAllJumbos" class="globalButton" value="<bean-el:message key="button.selectAll" bundle="ep.messages"/>"
          onclick="check(this.form.jumboIds, this);">
        <input type="button" class="globalButton" value="<bean-el:message key="button.remove" bundle="ep.messages"/>"
          onclick="if (isAnyChecked(this.form.jumboIds, '<bean-el:message key="ep.qualifier.atLeastOne" bundle="ep.messages"/>')) doQualifierRemove(1);">
      </div>
  </c:if>

      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Category" width="100%">
        <tr class="listHeader"> 
  <c:if test="${editable}">
          <th id="Checkboxes">&nbsp;</th>
  </c:if>
          <th id="Name" align="left" width="30%">
            <bean-el:message key="ep.qualifier.value.object.qualifier" bundle="ep.messages"/>
          </th>
          <th id="Value" align="left" width="60%">
            <bean-el:message key="ep.qualifier.value.object.specified.values" bundle="ep.messages"/>
          </th>
  <c:if test="${editable}">
          <th id="Actions" align="left" width="10%">
            <bean-el:message key="ep.header.actions" bundle="ep.messages"/>
          </th>
  </c:if>
        </tr>

    <c:forEach var="qualifier" items="${jumbos}" varStatus="status">

      <c:choose>
        <c:when test="${(status.count + 1) % 2 == 0}">
        <tr class="listEven">
        </c:when> 
  	<c:otherwise>
        <tr class="listOdd">
	</c:otherwise>
      </c:choose>

      <c:if test="${editable}">
          <td headers="Checkboxes" align="center"><input type="checkbox" name="jumboIds"
            onclick="update(this.form.jumboIds, this.form.selectAllJumbos);"
            value="<c:out value="${qualifier.map.id}"/>"></td>
      </c:if>
          <td headers="Name">
            <c:out value="${qualifier.map.name}" />
          </td>
          <td headers="Value">
            <c:forEach var="value" items="${qualifier.map.selectedValues}" varStatus="valueStatus"><c:if test="${valueStatus.count != 1}">, </c:if><c:out value="${value.map.name}"/></c:forEach>
          </td>
      <c:if test="${editable}">
          <td headers="Actions">
            <a href="#" onclick="doQualifierValuesEdit(<c:out value="${qualifier.map.id}"/>,'<c:forEach var="value" items="${qualifier.map.selectedValues}" varStatus="valueStatus"><c:out value="${value.map.id}"/>;</c:forEach>');"><c:out
            value='${editImg}' escapeXml="false"/></a>
            <a href="#" onclick="doQualifierRemove(<c:out value="${qualifier.map.id}"/>);"><c:out
            value='${removeImg}' escapeXml="false"/></a>
          </td>
      </c:if>
        </tr>
        
    </c:forEach>

      </table>
</c:if>

<c:if test="${empty qualifiers && empty jumbos}">
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Category" width="100%">
        <tr class="listHeader"> 
  <c:if test="${editable}">
          <th id="Checkboxes">&nbsp;</th>
  </c:if>
          <th id="Name" align="left" width="30%">
            <bean-el:message key="ep.qualifier.value.object.qualifier" bundle="ep.messages"/>
          </th>
          <th id="Value" align="left" width="60%">
            <bean-el:message key="ep.qualifier.value.object.specified.values" bundle="ep.messages"/>
          </th>
  <c:if test="${editable}">
          <th id="Actions" align="left" width="10%">
            <bean-el:message key="ep.header.actions" bundle="ep.messages"/>
          </th>
  </c:if>
        </tr>
        <tr class="listOdd">
          <td colspan="4" align="center">
          <bean-el:message key="ep.qualifier.value.object.qualifiers.not.found" bundle="ep.messages"/>
          </td>
        </tr>
        </table>
</c:if>

      <!--end main content area here-->
    </td>
  </tr>
</table>
